<?php
if ( !defined( "IN_OP" ) )
{
    exit( "You can't access this file directly..." );
}
if ( $curruser['acl'] == 255 && $curruser['prev_id'] != 0 && !SubAccountRight( $curruser, 2 ) )
{
    exit();
}
if ( isset( $_SESSION['subaccount'] ) && $curruser['acl'] < 255 )
{
    exit();
}
if ( $curruser['enabled'] == 2 )
{
    exit();
}
$gametype = intval( getvar( "gametype" ) );
if ( $gametype )
{
    $ui = new UI_3D( true );
    $ui->header();
}
else
{
    $ui = new UI( true );
}
$tpl = new Template2();
$str = "<script>show_tree('".$curruser['account']."','list','".$curruser['enabled']."');</script>";
$tpl->load( "main", "acctree.htm" );
$tpl->set( "login_acct", $curruser['account'] );
$tpl->set( "login_acl", $curruser['acl'] );
$tpl->set( "str", $str );
$tpl->set( "gametype", $gametype );
if ( $curruser['acl'] == "255" )
{
    $rs = getdb( "SELECT `enabled`,count(`enabled`) FROM `k_user` GROUP BY `enabled` ORDER By `enabled` ASC" );
    $enabled = array();
    $enabled_val = array();
    $i = 0;
    while ( !$rs->eof )
    {
        $enabled[$i] = $rs->f[0];
        $enabled_val[$i] = $rs->f[1];
        ++$i;
        $rs->movenext();
    }
    if ( count( $enabled ) == 0 )
    {
        diemsg( "无任何人员资料!" );
    }
    if ( 3 < count( $enabled ) )
    {
        diemsg( "人员状态超出系统预设可用状态，请检查资料表!" );
    }
    if ( count( $enabled ) == 3 )
    {
        $val = $enabled_val[0] + $enabled_val[1] + $enabled_val[2];
        $tpl->set( "title", "<div id='mbr_account'>【帐号搜寻】<a class='tooltips' href='#tooltips'><b>(合计:{$val} 人)</b>" );
        $tpl->set( "rs0", $enabled_val[0] );
        $tpl->set( "rs1", $enabled_val[1] );
        $tpl->set( "rs2", $enabled_val[2] );
        $tpl->set( "rsAll", $val );
    }
    else
    {
        if ( count( $enabled ) == 2 )
        {
            $val = $enabled_val[0] + $enabled_val[1];
            if ( $enabled[0] == "0" && $enabled[1] == "1" )
            {
                $tpl->set( "title", "<div id='mbr_account'>【帐号搜寻】<a class='tooltips' href='#tooltips'><b>(合计:{$val} 人)</b>" );
                $tpl->set( "rs0", $enabled_val[0] );
                $tpl->set( "rs1", $enabled_val[1] );
                $tpl->set( "rs2", "0" );
                $tpl->set( "rsAll", $val );
            }
            else
            {
                if ( $enabled[0] == "1" && $enabled[1] == "2" )
                {
                    $tpl->set( "title", "<div id='mbr_account'>【帐号搜寻】<a class='tooltips' href='#tooltips'><b>(合计:{$val} 人)</b>" );
                    $tpl->set( "rs0", "0" );
                    $tpl->set( "rs1", $enabled_val[0] );
                    $tpl->set( "rs2", $enabled_val[1] );
                    $tpl->set( "rsAll", $val );
                }
                else
                {
                    if ( $enabled[0] == "0" && $enabled[1] == "2" )
                    {
                        diemsg( "无启用状态的人员资料!" );
                    }
                }
            }
        }
        else
        {
            if ( count( $enabled ) == 1 )
            {
                if ( $enabled[0] == "1" )
                {
                    $tpl->set( "title", "<div id='mbr_account'>【帐号搜寻】<a class='tooltips' href='#tooltips'><b>(合计:{$enabled_val[0]} 人)</b>" );
                    $tpl->set( "rs0", "0" );
                    $tpl->set( "rs1", $enabled_val[0] );
                    $tpl->set( "rs2", "0" );
                    $tpl->set( "rsAll", $enabled_val[0] );
                }
                else
                {
                    diemsg( "无启用状态的人员资料!" );
                }
            }
        }
    }
}
else
{
    echo "<script>\r\n\t      $(function(){\t       \r\n             $('#mbr_account').find('span').empty().remove();             \r\n           });\r\n         </script>";
    $tpl->set( "title", "<div id='mbr_account'>【帐号搜寻】" );
}
//
$acl=intval($curruser['acl']);
$tree='<table width="95%" border="0" cellspacing="1" cellpadding="0" class="tblMy3D" id="Menu_List">';
switch($acl)
{
	case 255:
        $tree.='<tr><td  class=" bgImg_0"  style="text-align:center;height:25px"><a target="mainAccFrame" href="op.php?op=admin&fp=manage">管理员管理</a></td></tr>';
        $tree.='<tr><td  class=" bgImg_0"  style="text-align:center;height:25px"><a target="mainAccFrame" href="op.php?op=admin&fp=subsidary&gametype=0">大股東管理</a></td></tr>';
		$tree.='<tr><td  class=" bgImg_0"  style="text-align:center;height:25px"><a target="mainAccFrame" href="op.php?op=subsidary&fp=shareowner&gametype=0">股东管理</a></td></tr>';
  		$tree.='<tr><td  class=" bgImg_0"  style="text-align:center;height:25px"><a target="mainAccFrame" href="op.php?op=shareowner&fp=genagent&prev_id=0&gametype=0">总代理商管理</a></td></tr>';
  		$tree.='<tr><td  class="bgImg_0"  style="text-align:center;height:25px"><a target="mainAccFrame" href="op.php?op=genagent&fp=agent&prev_id=0&gametype=0">代理商管理</a></td></tr>';
  		$tree.='<tr><td  class="bgImg_0"  style="text-align:center;height:25px"><a target="mainAccFrame" href="op.php?op=agent&fp=member&prev_id=0&gametype=0">会员管理</a></td></tr>';
		break;
	case 5:
		$tree.='<tr><td  class=" bgImg_0"  style="text-align:center;height:25px"><a target="mainAccFrame" href="op.php?op=subsidary&fp=shareowner&gametype=0">股东管理</a></td></tr>';
  		$tree.='<tr><td  class=" bgImg_0"  style="text-align:center;height:25px"><a target="mainAccFrame" href="op.php?op=shareowner&fp=genagent&prev_id=0&gametype=0">总代理商管理</a></td></tr>';
  		$tree.='<tr><td  class="bgImg_0"  style="text-align:center;height:25px"><a target="mainAccFrame" href="op.php?op=genagent&fp=agent&prev_id=0&gametype=0">代理商管理</a></td></tr>';
  		$tree.='<tr><td  class="bgImg_0"  style="text-align:center;height:25px"><a target="mainAccFrame" href="op.php?op=agent&fp=member&prev_id=0&gametype=0">会员管理</a></td></tr>';
		break;
	case 4:
 		$tree.='<tr><td  class=" bgImg_0"  style="text-align:center;height:25px"><a target="mainAccFrame" href="op.php?op=shareowner&fp=genagent&prev_id=0&gametype=0">总代理商管理</a></td></tr>';
  		$tree.='<tr><td  class="bgImg_0"  style="text-align:center;height:25px"><a target="mainAccFrame" href="op.php?op=genagent&fp=agent&prev_id=0&gametype=0">代理商管理</a></td></tr>';
  		$tree.='<tr><td  class="bgImg_0"  style="text-align:center;height:25px"><a target="mainAccFrame" href="op.php?op=agent&fp=member&prev_id=0&gametype=0">会员管理</a></td></tr>';
		break;
	case 3:
  		$tree.='<tr><td  class="bgImg_0"  style="text-align:center;height:25px"><a target="mainAccFrame" href="op.php?op=genagent&fp=agent&prev_id=0&gametype=0">代理商管理</a></td></tr>';
  		$tree.='<tr><td  class="bgImg_0"  style="text-align:center;height:25px"><a target="mainAccFrame" href="op.php?op=agent&fp=member&prev_id=0&gametype=0">会员管理</a></td></tr>';
		break;
	case 2:
  		$tree.='<tr><td  class="bgImg_0"  style="text-align:center;height:25px"><a target="mainAccFrame" href="op.php?op=agent&fp=member&prev_id=0&gametype=0">会员管理</a></td></tr>';
		break;
}
$tree.='</table>';
$tpl->set('tree',$tree);
$tpl->show( "main" );
echo "</body></html>";
?>